<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/common/tagPage.jsp" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>试做订单表</title>
    <meta name="keywords" content="中文"/>
    <meta name="description" content="下载"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <!-- basic styles -->
    <link href="${baseurl}statics/assets/css/bootstrap.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/font-awesome.min.css"/>

    <!--[if IE 7]>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/font-awesome-ie7.min.css"/>
    <![endif]-->
    <!-- fonts -->

    <link rel="stylesheet" href="${baseurl}statics/assets/css/fonts.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/translateelement.css"/>

    <!-- ace styles -->

    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace.min.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-rtl.min.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-skins.min.css"/>

    <!--[if lte IE 8]>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-ie.min.css"/>
    <![endif]-->

    <!-- inline styles related to this page -->
    <!-- 公共的js -->
    <script src="${baseurl}statics/assets/js/common.js"></script>
    <!-- ace settings handler -->

    <script src="${baseurl}statics/assets/js/ace-extra.min.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

    <!--[if lt IE 9]>
    <script src="${baseurl}statics/assets/js/html5shiv.js"></script>
    <script src="${baseurl}statics/assets/js/respond.min.js"></script>
    <![endif]-->
</head>

<body>

<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try {
            ace.settings.check('breadcrumbs', 'fixed')
        } catch (e) {
        }
    </script>

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="#">订单管理</a>
        </li>

        <li>
            <a href="${baseurl}tryOrder/selectList?roleId=1&adminId=1">试做订单列表</a>
        </li>
        <li class="active">试做订单详情</li>
    </ul><!-- .breadcrumb -->

</div>

<div class="page-content">
    <div class="row">
        <div class="col-xs-12">
            <div class="row">
                <div class="col-xs-12">
                    <h3 class="header smaller lighter blue">试做订单数据列表</h3>
                    <div class="table-header">
                        试做数据列表信息
                    </div>
                    <div class="table-responsive">

                        <div style="width: 20%">
                            <form class="form-search" action="${baseurl}tryOrder/selectList?roleId=${sysUserManage.roleId}&adminId=${sysUserManage.id}"
                                  method="post">
                                <div class="row" style="margin-top: 20px;float: left;">
                                    <div class="col-xs-12 col-sm-8">
                                        <div class="input-group">
                                            <input type="text" class="form-control search-query" name="keywords"
                                                   placeholder="请输入试做订单号"/>
                                            <span class="input-group-btn">
                                                <button type="submit" class="btn btn-purple btn-sm">
                                                    搜索
                                                    <i class="icon-search icon-on-right bigger-110"></i>
                                                </button>
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <!-- 时间筛选 -->
                        <table id="sample-table-2" class="table table-striped table-bordered table-hover"
                               style="margin-top: 20px; text-align: center; vertical-align: middle">
                            <thead>
                            <tr>
                                <th class="center">
                                    <label>
                                        <input type="checkbox" class="ace"/>
                                        <span class="lbl"></span>
                                    </label>
                                </th>
                                <th style="text-align: center">Id</th>
                                <th style="text-align: center">试做订单号</th>
                                <th style="text-align: center">申请时间</th>
                                <th style="text-align: center">样品信息</th>
                                <th style="text-align: center">试做信息</th>
                                <th style="text-align: center">收货信息</th>
                                <th style="text-align: center">业务状态</th>
                                <th style="text-align: center">
                                    业务操作
                                </th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${page.records}" var="tryOrderVo">
                                <tr >
                                    <td class="center" style="vertical-align: middle">
                                        <label>
                                            <input type="checkbox" class="ace"/>
                                            <span class="lbl"></span>
                                        </label>
                                    </td>
                                    <td  style="text-align: center;vertical-align: middle">${tryOrderVo.id}</td>
                                    <td style="text-align: center;vertical-align: middle">${tryOrderVo.tryNo}</td>
                                    <td style="text-align: center;vertical-align: middle">${fn:substring(tryOrderVo.applyTime,0,19)}</td>
                                    <td style="text-align: center;vertical-align: middle">
                                      样品:${tryOrderVo.model}  单价:${tryOrderVo.unitPrice}元/双
                                    </td>
                                    <td style="vertical-align: middle">
                                        <table  class="table table-striped table-bordered table-hover"
                                        style="margin-top: 20px;vertical-align:center;" >
                                            <tr  style="line-height: 200px;font-weight: bolder">
                                               <td style="text-align: center">
                                                    <c:if test="${tryOrderVo.sizeType==1}">标准码</c:if>
                                                    <c:if test="${tryOrderVo.sizeType==2}">欧码</c:if>
                                                    <c:if test="${tryOrderVo.sizeType==3}">美码</c:if>
                                                </td>
                                              <%--  <td class="cr-999">数量</td>--%>
                                                  <c:forEach items="${tryOrderVo.tryOrderInfoList}" var="info">
                                                      <td>${info.size}</td>
                                                  </c:forEach>
                                            </tr>
                                            <tr style="text-align: center">
                                                <td >数量</td>
                                                <c:forEach items="${tryOrderVo.tryOrderInfoList}" var="info">
                                                <td >${info.number}</td>
                                                </c:forEach>
                                            </tr>
                                        </table>
                                    </td >
                                    <td  style="vertical-align: middle;line-height: 27px">
                                        <c:if test="${tryOrderVo.province==tryOrderVo.city}">
                                                ${tryOrderVo.userName}(${tryOrderVo.userPhone})<br/>
                                            ${tryOrderVo.province}${tryOrderVo.counties}${tryOrderVo.address}
                                        </c:if>
                                        <c:if test="${tryOrderVo.province!=tryOrderVo.city}">
                                            ${tryOrderVo.userName}(${tryOrderVo.userPhone})<br/>
                                            ${tryOrderVo.province}${tryOrderVo.city}${tryOrderVo.counties}${tryOrderVo.address}
                                        </c:if>
                                    </td>
                                    <td  style="vertical-align: middle">
                                        <c:if test="${tryOrderVo.status == 1}">申请中</c:if>
                                        <c:if test="${tryOrderVo.status == 2}">试做中</c:if>
                                        <c:if test="${tryOrderVo.status == 3}">试做完成</c:if>
                                    </td>
                                    <td style="vertical-align: middle">
                                        <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
                                         <%--   <a class="blue" href="#" target="iframe_bt">
                                                <i class="icon-zoom-in bigger-130"></i>
                                            </a>
                                            <a class="green" href="#">
                                                <i class="icon-pencil bigger-130"></i>
                                            </a>
                                            <a class="red" href="javascript:onclick = del(${tryOrderVo.id});">
                                                <i class="icon-trash bigger-130"></i>
                                            </a>--%>
                                            <shiro:hasPermission name="tryOrder:check">
                                                <c:if test="${tryOrderVo.status == 1}">
                                                    <a href="javascript:onclick = changeStatus('${tryOrderVo.id}','${tryOrderVo.status}');">试做</a>
                                                </c:if>
                                                <c:if test="${tryOrderVo.status == 2}">
                                                    <a href="javascript:onclick = changeStatus('${tryOrderVo.id}','${tryOrderVo.status}');">完成</a>
                                                </c:if>
                                            </shiro:hasPermission>
                                        </div>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                        <jsp:include page="/WEB-INF/jsp/common/pageHelper.jsp"/>
                    </div>
                </div>
            </div>
        </div><!-- /.col -->
    </div><!-- /.row -->
</div><!-- /.page-content -->

<script type="text/javascript">
    window.jQuery || document.write("<script src='${baseurl}statics/assets/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='${baseurl}statics/assets/js/jquery-1.10.2.min.js'>" + "<" + "/script>");
</script>
<![endif]-->

<script type="text/javascript">
    if ("ontouchend" in document) document.write("<script src='${baseurl}statics/assets/js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>
<script src="${baseurl}statics/assets/js/bootstrap.min.js"></script>
<script src="${baseurl}statics/assets/js/typeahead-bs2.min.js"></script>


<script src="${baseurl}statics/assets/js/ace-elements.min.js"></script>
<script src="${baseurl}statics/assets/js/ace.min.js"></script>

<!-- inline scripts related to this page -->

<script type="text/javascript">
//    删除用户数据
    function del(orderId) {
        var k = window.confirm("确定是否要删除！");
        if (k) {
            $.ajax({
                url: "${baseurl}tryOrder/delete",
                data: {"id": orderId},
                type: "post",
                success: function (json) {
                    console.log(json.code);
                    if (json.code == 0) {
                        alert(json.message);
                        location.reload();
                    } else {
                        alert(json.message);
                    }
                },
                error: function (json) {
                    alert("error");
                }
            });
        }
    }

    jQuery(function ($) {
        var oTable1 = $('#sample-table-2').dataTable({
            "aoColumns": [
                {"bSortable": false},
                null, null, null, null, null,
                {"bSortable": false}
            ]
        });


        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });


        $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table')
            var off1 = $parent.offset();
            var w1 = $parent.width();
            var off2 = $source.offset();
            var w2 = $source.width();
            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
            return 'left';
        }
    })


 /*
 * 该变试做状态
 * id 试做id
 * status 状态  此状态需后台进行操作判断
 * */
 function changeStatus(id,status){
    var k;
    if(status=="1"){
        k = window.confirm("是否进行试做！");
    }
    if(status=="2") {
        k = window.confirm("是否完成试做！");
    }
    if (k) {
        $.ajax({
            url: "${baseurl}tryOrder/changeStatus",
            data: {"id": id,"status":status},
            type: "post",
            dataType:"json",
            success: function (json) {
                if (json.code == 0) {
                    alert(json.message);
                    location.reload();
                } else {
                    alert(json.message);
                }
            },
            error: function (json) {
                alert("error");
            }
        });
    }

}
</script>
</body>
</html>

